package com.jiangore.dao;

import com.jiangore.entity.Tag;
import com.jiangore.mapper.TagRowMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @Todo
 * @Author jiangtao
 * @CreateBy 2020-03-09 1:48 PM
 * @UpdateBy jiangtao
 * @Version v1.0
 */
@Repository
public class TagDao {

    @Autowired
    private JdbcTemplate twoJdbcTemplate;

    public Tag getById(int id) {
        String sql = "select * from t_tag where id = ?";
        Tag t = twoJdbcTemplate.queryForObject(sql, new TagRowMapper(), id);
        return t;
    }

    public int count() {
        String sql = "select count(*) from t_tag";
        int count = twoJdbcTemplate.queryForObject(sql, Integer.class);
        return count;
    }
}
